from cart.models import CartModel
from rest_framework import serializers

# class CartSerializer(serializers.ModelSerializer):
#
#     class Meta:
#         model = CartModel
#         fields = "__all__"

class CartSerializer(serializers.ModelSerializer):
    courselist = serializers.SerializerMethodField(read_only=True)
    def get_courselist(self, obj):
        return {'id':obj.course.id,'level':obj.course.level,'cname':obj.course.kname,'discount':obj.course.disc,'price':obj.course.price,'cover':str(obj.course.cimg)}
    class Meta:
        model = CartModel
        fields = "__all__"